package com.joy.openggl;

import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import com.joy.openggl.util.BufferUtil;

public class SmoothColoredSquare extends Square {

	private float[] colors = {
			 1f, 0f, 0f, 1f, // vertex 0 red
			 0f, 1f, 0f, 1f, // vertex 1 green
			 0f, 0f, 1f, 1f, // vertex 2 blue
			 1f, 0f, 1f, 1f, // vertex 3 magenta
			};

	private FloatBuffer colorBuffer = BufferUtil.floatBuffer(colors);

	@Override
	public void draw(GL10 gl) {
		// TODO Auto-generated method stub
//		gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
		// Enable the color array buffer to be
		//used during rendering.
		gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
		// Point out the where the color buffer is.
		gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
		super.draw(gl);
		// Disable the color buffer.
		gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
	}
	
}
